package edu.ucsc.gameAI.fsm;

import pacman.game.Game;
import edu.ucsc.gameAI.IAction;
import edu.ucsc.gameAI.ICondition;
import edu.ucsc.gameAI.conditions.PacmanInRegion;

public class Transition implements ITransition {

	IState targetState;
	IAction action;
	ICondition condition;
	private String name;

	public Transition(){
		//empty constructor
	}
	
	public Transition(String name){
		this.name = name;
	}
	
	@Override
	public IState getTargetState() {
		return targetState;
	}

	@Override
	public void setTargetState(IState targetState) {
		this.targetState = targetState;
	}

	@Override
	public IAction getAction() {
		return action;
	}

	@Override
	public void setAction(IAction action) {
		this.action = action;
	}

	@Override
	public void setCondition(ICondition condition) {
		this.condition = condition;
	}

	@Override
	public boolean isTriggered(Game game) {
		return condition.test(game);
	}
	
	@Override
	public String toString()
	{
		return "condition: " + condition.toString() + " target State " + this.targetState.getName();
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

}
